def deal_grade(initial_grade, change_grade):
    n = len(initial_grade)
    # 构造差分数组
    diff_array = [0] * n
    diff_array[0] = initial_grade[0]
    for i in range(1,n):
        diff_array[i] = initial_grade[i] - initial_grade[i - 1]

    for ls in change_grade:
        begin, end, scores = ls
        diff_array[begin - 1] += scores
        if end < n:  # j = end-1;j+1 -= scores
            diff_array[end] -= scores

    # 直接在initial_grade上原地计算前缀和还原最终结果
    initial_grade[0] = diff_array[0]
    for i in range(1, n):
        initial_grade[i] = diff_array[i] + initial_grade[i - 1]

    return initial_grade

students,times = map(int,input().split())
initial_grade = list(map(int,input().split()))
change_grade = [list(map(int, input().split())) for _ in range(times)]

result_list = deal_grade(initial_grade,change_grade)
print(min(result_list))
